{% extends "base.html" %}

{% block content %}
<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow-sm">
                <div class="card-body">
                    <h2 class="card-title mb-4">添加饮食记录</h2>
                    <form method="post">
                        <div class="row g-3">
                            <div class="col-md-6">
                                <label for="meal_date" class="form-label">日期</label>
                                <input type="date" class="form-control" id="meal_date" name="meal_date" 
                                       required value="{{ today }}">
                            </div>
                            <div class="col-md-6">
                                <label for="meal_time" class="form-label">时间</label>
                                <input type="time" class="form-control" id="meal_time" name="meal_time" 
                                       required value="{{ current_time }}">
                            </div>
                            <div class="col-md-6">
                                <label for="meal_type" class="form-label">餐食类型</label>
                                <select class="form-select" id="meal_type" name="meal_type" required>
                                    <option value="早餐">早餐</option>
                                    <option value="午餐">午餐</option>
                                    <option value="晚餐">晚餐</option>
                                    <option value="加餐">加餐</option>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label for="food_name" class="form-label">食物名称</label>
                                <input type="text" class="form-control" id="food_name" name="food_name" 
                                       required maxlength="100">
                            </div>
                            <div class="col-md-6">
                                <label for="calories" class="form-label">热量 (kcal)</label>
                                <input type="number" class="form-control" id="calories" name="calories" 
                                       min="0" step="1">
                            </div>
                            <div class="col-md-6">
                                <label for="protein" class="form-label">蛋白质 (g)</label>
                                <input type="number" class="form-control" id="protein" name="protein" 
                                       min="0" step="0.1">
                            </div>
                            <div class="col-md-6">
                                <label for="fat" class="form-label">脂肪 (g)</label>
                                <input type="number" class="form-control" id="fat" name="fat" 
                                       min="0" step="0.1">
                            </div>
                            <div class="col-md-6">
                                <label for="carbs" class="form-label">碳水化合物 (g)</label>
                                <input type="number" class="form-control" id="carbs" name="carbs" 
                                       min="0" step="0.1">
                            </div>
                            <div class="col-12">
                                <label for="note" class="form-label">备注</label>
                                <textarea class="form-control" id="note" name="note" rows="3"></textarea>
                            </div>
                            <div class="col-12">
                                <div class="d-grid gap-2">
                                    <button type="submit" class="btn btn-primary">保存</button>
                                    <a href="{{ url_for('main.meal_records') }}" class="btn btn-secondary">返回</a>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 